package br.mikhas.container.config.convertion;

import br.mikhas.util.Assert;
import br.mikhas.util.Numbers;

/**
 * Provides convertion for number types
 * 
 * @author Mikhail Domanoski
 * 
 */
public class NumberConverter implements Converter {

	@Override
	public boolean accepts(Class<?> type) {
		Assert.notNull(type);
		return Numbers.isNumber(type);
	}

	@SuppressWarnings("unchecked")
	@Override
	public Object convert(String literalValue, Class<?> type) {
		return Numbers.getNumber((Class<? extends Number>) type, literalValue);
	}
}
